import pandas as pd
import numpy as np
df1 = pd.DataFrame([['王童瑶','女',20,'大同'],
                    ['王嘉英','女',18,'长春'],
                    ['王润文','女',18,'广州'],
                    ['范晨钰','女',18,'洛阳'],
                    ['吴露芳','女',20,'庆元']],
                    index=['one', 'two', 'three', 'four','five'],
                    columns=['name','gender','age','city'])
print(df1)
print(df1.head())
data = df1[['name']][:3]
print('访问name列前3行的数据：')

data=df1.loc['three',['name','city']]
print('获取第3行name列和city列数据的结果:\n',data)

data =df1.iloc[0]
print ('获取第0行数据的结果\n',data)

data = df1.iloc[[1,2],[3,0,1]]
print ('获取第1和第2行中第3、0和1列数据的结果：\n',data)

data=df1.iloc[:, :3][df1.age > 18]
print('选取前3行中C列中大于18的结果\n',data)